def guessNum():
  import random,time
  print("欢迎来到猜数字游戏")
  x =random.randint(1,100)
  flag = input("是否开始？y/n")
  if flag == "y":
    s=time.time()
    while True:
      y = int(input("请输入数字："))
      if y > x:
        print("太大了")
      elif y < x:
        print("太小了")
      else:
        print("恭喜你猜对了")
        break
    e=time.time()
    print("你用了%.2f秒"%(e-s))
  else:
    print("游戏结束")
guessNum()